package redisinit

import (
	"2210a/user-profile/appconfig"
	"fmt"
	"github.com/go-redis/redis"
)

var (
	ClientRedis *redis.Client
)

func InitRedis() {
	redisConf := appconfig.AppConf.RedisConfig
	ClientRedis = redis.NewClient(&redis.Options{
		Addr:     redisConf.Addr,
		Password: redisConf.Password, // no password set
		DB:       redisConf.Db,       // use default DB
	})

	_, err := ClientRedis.Ping().Result()
	if err != nil {
		fmt.Println("Redis连接失败", err)
		return
	}
	fmt.Println("Redis连接成功")
}
